home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / libgimp / gimpgradientselect_pdb.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-26  |  4.8 KB  |  172 lines

  1. /* LIBGIMP - The GIMP Library
  2.  * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
  3.  *
  4.  * gimpgradientselect_pdb.c
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  */
  21.  
  22. /* NOTE: This file is autogenerated by pdbgen.pl */
  23.  
  24. #include <string.h>
  25.  
  26. #include "gimp.h"
  27.  
  28. /**
  29.  * gimp_gradients_popup:
  30.  * @gradients_callback: The callback PDB proc to call when gradient selection is made.
  31.  * @popup_title: Title to give the gradient popup window.
  32.  * @initial_gradient: The name of the pattern to set as the first selected.
  33.  * @sample_size: Size of the sample to return when the gradient is changed.
  34.  *
  35.  * Invokes the Gimp gradients selection.
  36.  *
  37.  * This procedure popups the gradients selection dialog.
  38.  *
  39.  * Returns: TRUE on success.
  40.  */
  41. gboolean
  42. gimp_gradients_popup (gchar *gradients_callback,
  43.               gchar *popup_title,
  44.               gchar *initial_gradient,
  45.               gint   sample_size)
  46. {
  47.   GimpParam *return_vals;
  48.   gint nreturn_vals;
  49.   gboolean success = TRUE;
  50.  
  51.   return_vals = gimp_run_procedure ("gimp_gradients_popup",
  52.                     &nreturn_vals,
  53.                     GIMP_PDB_STRING, gradients_callback,
  54.                     GIMP_PDB_STRING, popup_title,
  55.                     GIMP_PDB_STRING, initial_gradient,
  56.                     GIMP_PDB_INT32, sample_size,
  57.                     GIMP_PDB_END);
  58.  
  59.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  60.  
  61.   gimp_destroy_params (return_vals, nreturn_vals);
  62.  
  63.   return success;
  64. }
  65.  
  66. /**
  67.  * gimp_gradients_close_popup:
  68.  * @gradients_callback: The name of the callback registered for this popup.
  69.  *
  70.  * Popdown the Gimp gradient selection.
  71.  *
  72.  * This procedure closes an opened gradient selection dialog.
  73.  *
  74.  * Returns: TRUE on success.
  75.  */
  76. gboolean
  77. gimp_gradients_close_popup (gchar *gradients_callback)
  78. {
  79.   GimpParam *return_vals;
  80.   gint nreturn_vals;
  81.   gboolean success = TRUE;
  82.  
  83.   return_vals = gimp_run_procedure ("gimp_gradients_close_popup",
  84.                     &nreturn_vals,
  85.                     GIMP_PDB_STRING, gradients_callback,
  86.                     GIMP_PDB_END);
  87.  
  88.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  89.  
  90.   gimp_destroy_params (return_vals, nreturn_vals);
  91.  
  92.   return success;
  93. }
  94.  
  95. /**
  96.  * gimp_gradients_set_popup:
  97.  * @gradients_callback: The name of the callback registered for this popup.
  98.  * @gradient_name: The name of the gradient to set as selected.
  99.  *
  100.  * Sets the current gradient selection in a popup.
  101.  *
  102.  * Sets the current gradient selection in a popup.
  103.  *
  104.  * Returns: TRUE on success.
  105.  */
  106. gboolean
  107. gimp_gradients_set_popup (gchar *gradients_callback,
  108.               gchar *gradient_name)
  109. {
  110.   GimpParam *return_vals;
  111.   gint nreturn_vals;
  112.   gboolean success = TRUE;
  113.  
  114.   return_vals = gimp_run_procedure ("gimp_gradients_set_popup",
  115.                     &nreturn_vals,
  116.                     GIMP_PDB_STRING, gradients_callback,
  117.                     GIMP_PDB_STRING, gradient_name,
  118.                     GIMP_PDB_END);
  119.  
  120.   success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
  121.  
  122.   gimp_destroy_params (return_vals, nreturn_vals);
  123.  
  124.   return success;
  125. }
  126.  
  127. /**
  128.  * _gimp_gradients_get_gradient_data:
  129.  * @name: The gradient name (\"\" means current active gradient).
  130.  * @sample_size: Size of the sample to return when the gradient is changed.
  131.  * @width: The gradient sample width (r,g,b,a).
  132.  * @grad_data: The gradient sample data.
  133.  *
  134.  * Retrieve information about the specified gradient (including data).
  135.  *
  136.  * This procedure retrieves information about the gradient. This
  137.  * includes the gradient name, and the sample data for the gradient.
  138.  *
  139.  * Returns: The gradient name.
  140.  */
  141. gchar *
  142. _gimp_gradients_get_gradient_data (gchar    *name,
  143.                    gint      sample_size,
  144.                    gint     *width,
  145.                    gdouble **grad_data)
  146. {
  147.   GimpParam *return_vals;
  148.   gint nreturn_vals;
  149.   gchar *ret_name = NULL;
  150.  
  151.   return_vals = gimp_run_procedure ("gimp_gradients_get_gradient_data",
  152.                     &nreturn_vals,
  153.                     GIMP_PDB_STRING, name,
  154.                     GIMP_PDB_INT32, sample_size,
  155.                     GIMP_PDB_END);
  156.  
  157.   *width = 0;
  158.  
  159.   if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
  160.     {
  161.       ret_name = g_strdup (return_vals[1].data.d_string);
  162.       *width = return_vals[2].data.d_int32;
  163.       *grad_data = g_new (gdouble, *width);
  164.       memcpy (*grad_data, return_vals[3].data.d_floatarray,
  165.           *width * sizeof (gdouble));
  166.     }
  167.  
  168.   gimp_destroy_params (return_vals, nreturn_vals);
  169.  
  170.   return ret_name;
  171. }
  172.